/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.musigma.rm;

import com.gcliff.model.glpks.Sso;
import com.musigma.model.SmtbUser;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.RowMapper;

/**
 *
 * @author krishna
 */
public class SmtbUserRM implements RowMapper<Object> {

    public Object mapRow(ResultSet resultSetOBJ, int line) throws SQLException {
        SmtbUserRowMapper rowMapper = new SmtbUserRowMapper();
        return rowMapper.extractData(resultSetOBJ);
    }
}

class SmtbUserRowMapper implements ResultSetExtractor<Object> {

    BeanFactory factory = (BeanFactory) (new ClassPathXmlApplicationContext(new String[]{"classpath:ApplicationContext.xml"}));

    public Object extractData(ResultSet resultSetOBJ) throws SQLException {
        SmtbUser setterMapObject = (SmtbUser) factory.getBean("smtbUser");
        setterMapObject.setSmtbUserId(resultSetOBJ.getString("SMTB_USER_ID"));
        setterMapObject.setUserName(resultSetOBJ.getString("USER_NAME"));
        setterMapObject.setUserPassword(resultSetOBJ.getString("USER_PASSWORD"));
        setterMapObject.setFullName(resultSetOBJ.getString("FULL_NAME"));
        setterMapObject.setNickName(resultSetOBJ.getString("NICK_NAME"));
        setterMapObject.setActSts(resultSetOBJ.getString("ACT_STS"));
        return setterMapObject;
    }
}